#include "Settings.h"

namespace po = boost::program_options;

template<> Settings* Ogre::Singleton<Settings>::msSingleton = 0;

Settings::Settings()
{
}

bool Settings::initialise()
{
    try
    {
        po::options_description desc;
        desc.add_options()
            ("General.Liquids",po::value<bool>()->default_value(true),"Enables liquids")
            ("General.Plants",po::value<bool>()->default_value(true),"Enables plants")
            ("General.PlantBatchDistance",po::value<double>()->default_value(2000.0),"Batch drawing distance for plants")
            ("General.PlantImpostorDistance",po::value<double>()->default_value(4000.0),"Impostor drawing distance for plants")
            ("General.CameraSpeed",po::value<double>()->default_value(120.0),"Camera Speed")

            ("Time.Sunrise",po::value<double>()->default_value(6.0),"Time of sunrise")
            ("Time.Sunset",po::value<double>()->default_value(21.0),"Time of sunset")
            ("Time.StartingTime",po::value<double>()->default_value(8.0),"Starting Time")
            ("Time.TimeMultiplier",po::value<double>()->default_value(0.01),"Time Multiplier")

            ("PolyVoxGenerator.XScale",po::value<double>()->default_value(40.0),"PolyVoxGenerator tile X scale")
            ("PolyVoxGenerator.YScale",po::value<double>()->default_value(40.0),"PolyVoxGenerator tile Y scale")
            ("PolyVoxGenerator.ZScale",po::value<double>()->default_value(5.0),"PolyVoxGenerator tile Z scale")
            ("PolyVoxGenerator.PageSizeX",po::value<int>()->default_value(16),"PolyVoxGenerator page x tile size")
            ("PolyVoxGenerator.PageSizeY",po::value<int>()->default_value(16),"PolyVoxGenerator page y tile size")
            ("PolyVoxGenerator.PageSizeZ",po::value<int>()->default_value(128),"PolyVoxGenerator page z tile size")
            ("PolyVoxGenerator.PageDistanceX",po::value<int>()->default_value(12),"PolyVoxGenerator page x tile view distance")
            ("PolyVoxGenerator.PageDistanceY",po::value<int>()->default_value(12),"PolyVoxGenerator page y tile view distance")
            ("PolyVoxGenerator.PageDistanceZ",po::value<int>()->default_value(2),"PolyVoxGenerator page z tile view distance")
            ("PolyVoxGenerator.UseFaceNormals",po::value<bool>()->default_value(false),"PolyVoxGenerator use face rather than vertex normals")
            ("PolyVoxGenerator.DecimateMeshes",po::value<bool>()->default_value(false),"PolyVoxGenerator decimation enable")
            ("PolyVoxGenerator.DecimationFactor",po::value<float>()->default_value(0.9999f),"PolyVoxGenerator decimation factor")

            ("Input.ForwardKey",po::value<std::string>()->default_value("KC_W"),"Forward Key")
            ("Input.BackwardKey",po::value<std::string>()->default_value("KC_S"),"Backward Key")
            ("Input.LeftKey",po::value<std::string>()->default_value("KC_A"),"Left Key")
            ("Input.RightKey",po::value<std::string>()->default_value("KC_D"),"Right Key")
            ("Input.UpKey",po::value<std::string>()->default_value("KC_R"),"Up Key")
            ("Input.DownKey",po::value<std::string>()->default_value("KC_F"),"Down Key")
            ("Input.SpeedKey",po::value<std::string>()->default_value("KC_LSHIFT"),"Speed Key")
            ;

        po::store(po::parse_config_file<char>("overseer.ini",desc,true),vm);
        po::notify(vm);
    }
    catch(std::exception &e)
    {
        std::cout << e.what() << std::endl;
    }
    return true;
}